"""
C/S通信模式,服务端实现
"""
import rospy
from plumbing_c_s.srv import *


def response_callback(request):
    num1 = request.num1
    num2 = request.num2
    sum = num1 + num2
    response = AddIntsResponse()
    response.sum = sum
    rospy.loginfo("客户端解析到的数据是:num1=%d,num2=%d,返回结果sum=%d", num1, num2, sum)
    return response


if __name__ == '__main__':
    rospy.init_node("server_py")
    server = rospy.Service("addInts", AddInts, response_callback)
    rospy.loginfo("服务端启动成功!")
    rospy.spin()
